/**
 * Arrays class
 *
 * @author sergei
 *
 * @date 24 Jan 2013
 */

import java.util.Scanner;

class Arrays {
    /**
     * Method InputSize returns size of the array that user will
     * input after.
     * @result Size of the array to be created.
     * @throws IllegalArgumentException if entered wrong data.
     */
    private static int inputSize() 
            throws IllegalArgumentException {
	    System.out.print("Enter size of the array you gonna input: ");
        
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        
        /* Checking if input number is positive */
	    if (n <= 0) {
            throw new IllegalArgumentException("Wrong value!");
        }

	    return n;
    }

    /**
     * Method InputArray returns array we will work with.
     * @param int size Size of input array.
     * @return int[] Array of entered numbers.
     */
    private static int[] inputArray(int size) {
        int[] result = new int[size];
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < size; i++) {
            System.out.print("[" + i + "]=");
            result[i] = scanner.nextInt();
        }
        return result;
    }
    
    /**
     * Method findLowestDistance returns index of first element in couple with
     * the lowest distance between the elements of couple.
     * @param int[] array Array of numbers.
     * @return int        Index of the first element in needed couple.
     */
    private static int findLowestDistance(int[] array) {
        int index = 0;
        for (int i = 1; i < array.length - 1; i++) {
            if (Math.abs(array[i]-array[i+1]) < 
                    Math.abs(array[index] - array[index+1])) {
                index = i;
            }
        }
        return index;
    }
    
    public static void main(String[] args) {
        int size;   // Size of input array.
        int[] array;  // Array to work with.

        size = Arrays.inputSize();        
        array = Arrays.inputArray(size);
        
        int result;

        result = Arrays.findLowestDistance(array);

        System.out.println("The first pair with lowest distance starts on " 
                + result );
    }
}


